package Rules;

import Logic.GameEngine;

public class LuckyRoll extends BoardRule {
	int luckyNum;
	int luckyLimit;
	private int rollsInRow;
	
	

	public LuckyRoll(GameEngine ge, int luckyNum, int luckyLimit) {
		super(ge);
		this.luckyNum = luckyNum;
		this.luckyLimit = luckyLimit;
		rollsInRow = 0;
	}



	@Override
	public void executeRule() {
		int diceVal = ge.getSteps();
		if (diceVal == luckyNum && ge.hasPlayer(ge.getCurrentPlayer())) {
			rollsInRow++;
		
			if (rollsInRow == (luckyLimit - 1)){
				rollsInRow = 0;
				ge.setSteps(0);
				//this works bcs logic in move
				ge.move(Integer.MIN_VALUE, ge.getCurrentPlayer());
				
			}
			else {
				ge.setStepPlayers(false);
			}
		}
		else {
			rollsInRow = 0;
		}
		
	}
	

}
